// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import VueRouter from 'vue-router';
import VueRsource from 'vue-resource'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App';
import Routers from './router/router.js';
import $ from 'jquery';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap';
import 'cropper/dist/cropper.css';
import 'cropper/dist/cropper.js';
require('font-awesome-webpack');
import Moment from 'moment'
var echarts = require('echarts');

Vue.config.productionTip = false

Vue.use(VueRouter);
Vue.use(VueRsource);
Vue.use(ElementUI);
Vue.use(Moment);

const RouterConfig = {
  routes: Routers
};
const router = new VueRouter(RouterConfig);
router.beforeEach((to, from, next) => {
  if (to.path == '/Login') {
    sessionStorage.removeItem('user');
  }
  let result = sessionStorage.getItem('user');
  if (!result && to.path != '/Login') {
    next({ path: '/Login' })
  } else {
    next()
  }
});
Vue.prototype.urlConfig = 'http://192.168.1.23:9295'; //全局url
// Vue.prototype.urlConfig = 'http://localhost:17659'; //全局url

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router: router,
  components: { App },
  template: '<App/>'
})
